package cn.ecut.servlet;


import cn.ecut.services.GoodServices;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/lost/deal")
public class DealLostServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	    int goodid=-1;
		GoodServices gservice=new GoodServices();
		if(request.getParameter("changegoodid")!=null){
			goodid=(Integer.parseInt(request.getParameter("changegoodid")));
			gservice.updateGoodState(goodid);
		}else if(request.getParameter("deletegoodid")!=null){
			goodid=(Integer.parseInt(request.getParameter("deletegoodid")));
			gservice.deleteGood(goodid);
		}
		response.sendRedirect("/mypost.jsp");
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request,response);
	}

}
